import request from '../../../utils/request';
import {edu} from '../../../config/config';

function createGroup(groupIconId, groupName, description, groupType, password) {
	return request(edu('/api/edu/createGroup'), {
    	data: {
    		groupIconId: groupIconId,
    		groupName: groupName,
    		description: description,
    		groupType: groupType,
    		password: password,
    	}
    });
}

function listGroupByUserId() {
	return request(edu('/api/edu/listGroupByUserId'));
}

function getGroupDetailByGroupId(groupId) {
	return request(edu('/api/edu/getGroupDetailByGroupId'), {
		data: {
			groupId: groupId
		}
	});
}

function removeGroup(groupId) {
	return request(edu('/api/edu/removeGroup'), {
		data: {
			groupId: groupId
		}
	});
}

function joinGroup(groupId, memberType) {
	return request(edu('/api/edu/joinGroup'), {
		data: {
			groupId: groupId,
			memberType: memberType,
		}
	});
}

function sendMessageToGroup(groupId, message) {
	return request(edu('/api/edu/sendMessageToGroup'), {
		data: {
			groupId: groupId,
			message: message,
		}
	});
}

export {
    createGroup,
    listGroupByUserId,
    getGroupDetailByGroupId,
    removeGroup,
    joinGroup,
    sendMessageToGroup,
};